package model;

import java.awt.Dimension;
import java.awt.Graphics;

/**
 * Model holds the information for the SLogo workspace.
 *
 * @author Matthew Roy & Angelica Schwartz
 */
public class Model {
    
    private final Interpreter myInterpreter;
    private final Environment myEnvironment;

    /**
     * Create a game of the given size with the given display for its shapes.
     *
     * @param canvas is the Canvas view model
     */
    public Model(Dimension size) {
        myEnvironment = new Environment(size);
        //TODO: make turtle in center of the screen                
        myInterpreter = new Interpreter(myEnvironment);
    }

    /**
     * Sends the user command string to the interpreter.
     *
     * @param command string
     * @return command result
     * @throws SyntaxErrorException 
     */
    public int update(String command) throws SyntaxErrorException {
       return myInterpreter.interpretAndExecute(command);
    }

    public void paint(Graphics pen) {
        myEnvironment.paint(pen);
    }

    public Environment getEnvironment() {
        return myEnvironment;
    }

}
